﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

public partial class OverallFinanceReport : System.Web.UI.Page
{
    private const string sourceTableOrView = "vOverallFinanceReport";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["Year"] == null || Request.QueryString["Branch"] == null)
        {
            Response.Redirect("ViewReports.aspx");
        }
        else
        {
            string filterString = null;
            string year = Request.QueryString["Year"] + "-01-01";
            DAL.AddFilter(ref filterString, "CreatedDate", year, @"'", sourceTableOrView);
            DAL.AddFilter(ref filterString, "PinCode", Request.QueryString["Branch"], @"'", sourceTableOrView);

            ReportDocument rpt = null;
            rpt = DAL.CreateCrystalReportDocument(filterString, "ServiceName", MapPath("~/Pages_Admin/Reports/Report File/OverallFinanceReport.rpt"), sourceTableOrView);
            CrystalReportViewer1.ReportSource = rpt;
        }
        CrystalReportViewer1.DataBind();
    }
}
